package com.xuxin.baby.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.xuxin.baby.R;
import com.xuxin.baby.bean.ChildDataBean;
import com.xuxin.baby.utils.BaseUtils;

import org.jetbrains.annotations.NotNull;

/**
 * Created by xu_xin
 * Created on 2020.08.04 0004
 * 记睡眠
 */
public class ChildSleepAdapter extends BaseQuickAdapter<ChildDataBean.ResultBean.ItemsBean, BaseViewHolder> {

    public ChildSleepAdapter() {
        super(R.layout.item_child_data);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, ChildDataBean.ResultBean.ItemsBean itemsBean) {
        int hour = (int) (itemsBean.getSleepMinutes() / 60);
        int minutes = (int) (itemsBean.getSleepMinutes() - hour * 60);
        if (hour > 0) {
            String name = "睡眠时长: " + hour + "小时; " + minutes + "分";
            holder.setText(R.id.item_child_data_name, name);
        } else {
            String name = "睡眠时长: " + minutes + "分";
            holder.setText(R.id.item_child_data_name, name);
        }
        holder.setText(R.id.item_child_data_time, BaseUtils.getTime(itemsBean.getEventDate()));
    }
}